﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ARS.DataBase.Provider
{
    public class DataPagingProvider 
    {
        private DataPagingProvider()
        {
        }

        private static IDataPagingProvider _instance = null;
        private static object lockHelper = new object();

        static DataPagingProvider()
        {
            GetProvider();
        }

        private static void GetProvider()
        {
            Type type = Type.GetType(string.Format("ARS.DataBase.{0}.DataPagingProvider, ARS", DbFactory.GetDbTypeStr()));//DbMySql
            _instance = (IDataPagingProvider)Activator.CreateInstance(type);
        }

        public static IDataPagingProvider GetInstance()
        {
            if (_instance == null)
            {
                lock (lockHelper)
                {
                    if (_instance == null)
                    {
                        GetProvider();
                    }
                }
            }
            return _instance;
        }

        public static void ResetDbProvider()
        {
            _instance = null;
        }
    }

}
